package com.droowa.model.dao;

import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.droowa.domain.BusinessRecord;

@Repository
public class BusinessRecordDAOMybatisImpl implements BusinessRecordDAO{

	@Autowired
	private SqlSessionTemplate session; 
	
	@Override
	public int insertBusinessRecord(BusinessRecord businessRecord)
			throws SQLException {
		return session.insert(makeSqlId("insertBusinessRecord"), businessRecord);
	}

	@Override
	public int deleteBusinessRecord(String businessNo) throws SQLException {
		return session.delete(makeSqlId("deleteBusinessRecord"), businessNo);
	}

	@Override
	public int updateBusinessRecord(BusinessRecord businessRecord)
			throws SQLException {
		return session.update(makeSqlId("updateBusinessRecord"), businessRecord);
	}
	
	@Override
	public List<BusinessRecord> selectBusinessRecord() throws SQLException {
		return session.selectList(makeSqlId("selectBusinessRecord"));
	}

	@Override
	public List<BusinessRecord> selectBusinessRecordByAll(
			HashMap map) throws SQLException {
		return session.selectList(makeSqlId("selectBusinessRecordByAll"), map);
	}

	@Override
	public int selectRowCount(HashMap map) throws SQLException {
		return session.selectOne(makeSqlId("selectRowCount"), map);
	}

	private String makeSqlId(String id){
		return "droowa.businessRecord."+id;
	}
	
}
